
import { contents_query } from "../../db/insert"
import { tv_series } from "../../youku/tv_series/tv_series_item";
import { count_equal } from "../../db/insert"
import { config, objContent } from "../contents/config"
import { resolve } from "path";
const _ = require("lodash")





// 一个完整分页数据的插入 函数封装
async function contents_query_fn({ searchValue, start, end }) {
    let res = await contents_query({ searchValue, start, end });


    _.forEach(res, item => {
        // console.log(item)

        tv_series({
            uri: 'https:' + item.videoLink,
            dbs: item.category
        })
    })

    // fs.writeFileSync("./查询结果.json", JSON.stringify(res), 'utf-8');
}






//获取满足添加的数据

let pamValue = config[0]

//获取满足条件tv_vierces的总条数
async function get_term() {

    let res = await count_equal(pamValue.category);

    return JSON.parse(res)[0]['COUNT(id)']

}


export async function insert_all() {

    let res = await get_term();
    for (let i = 0; i < res;) {

        contents_query_fn(new objContent(pamValue.category, i, i + 50))

        i += 50;
    }


}






